<template>
  <div class="baobaotuan">
    <header>
      <transition name='absd' mode="out-in">
        <keep-alive>
          <component :is="coms[top]"></component>
        </keep-alive>
      </transition>
      <div class="nax">
        <span v-for='(item,index) in topArr' :key="index" @click='qiehuan(index)' :class="{active:top == index}">
          {{item}}
        </span>
      </div>
    </header>
  </div>
</template>

<script>
import MyDijia from '../../components/MyDijia.vue'
import MyRush from '../../components/MyRush.vue'

export default {
  data() {
    return {
      top: 0,
      topArr: ['正在抢购', '上新预告'],
      coms: [MyRush, MyDijia]

    }
  },
  methods: {
    qiehuan(index) {
      this.top = index
    }
  },
}
</script>

<style lang='scss' scoped>
.absd-enter {
  opacity: 0;
}
.absd-enter-active {
  transition: all 0.4s;
}
.absd-enter-to {
  opacity: 1;
}
.absd-leave {
  opacity: 1;
}
.absd-leave-active {
  transition: all 0.4s;
}
.absd-leave-to {
  opacity: 0;
}
.active {
  color: orchid;
}
.baobaotuan {
  width: 100%;
  height: 100%;
}
.nax {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  // background-color: aqua;
  border-bottom: 1px solid gray;
  background-color: #fff;
  position: fixed;
  top: 0;
  line-height: 40px;
}
header {
  width: 100%;
  height: 100%;
  // display: flex;
  // align-items: center;
  // background-color: aqua;

  span {
    margin-right: 22px;
  }
}
</style>